package org.example.test.infrastructure.dao;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.example.infrastructure.dao.IGroupBuyActivityDao;
import org.example.infrastructure.dao.po.GroupBuyActivity;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
public class GroupBuyActivityDaoTest {

    @Resource
    private IGroupBuyActivityDao groupBuyActivityDao;
    private GroupBuyActivity groupBuyActivity;

    @Test
    public void test_()
    {
        List<GroupBuyActivity> groupBuyActivities=groupBuyActivityDao.queryGroupBuyActivityList();
        log.info("测试结果:{}", JSON.toJSONString(groupBuyActivities));
    }
    @Test
    public void test_ADD()
    {
        GroupBuyActivity activity = new GroupBuyActivity();

        // 设置属性值
        Long id = 11111L;
        Long activityId = 1001L;
        String activityName = "限时拼团活动";
        String discountId = "2023";
        Integer groupType = 0; // 自动成团
        Integer takeLimitCount = 5;
        Integer target = 10;
        Integer validTime = 120; // 120分钟
        Integer status = 1; // 生效
        Date startTime = new Date();
        Date endTime = new Date(System.currentTimeMillis() + 86400000); // 24小时后
        String tagId = "TAG_VIP";
        String tagScope = "ALL";
        Date createTime = new Date();
        Date updateTime = new Date();

        // 设置属性（假设类中有对应的setter方法）
        activity.setId(id);
        activity.setActivityId(activityId);
        activity.setActivityName(activityName);
        activity.setDiscountId(discountId);
        activity.setGroupType(groupType);
        activity.setTakeLimitCount(takeLimitCount);
        activity.setTarget(target);
        activity.setValidTime(validTime);
        activity.setStatus(status);
        activity.setStartTime(startTime);
        activity.setEndTime(endTime);
        activity.setTagId(tagId);
        activity.setTagScope(tagScope);
        activity.setCreateTime(createTime);
        activity.setUpdateTime(updateTime);
        Boolean a=groupBuyActivityDao.addGroupBuyActivity(activity);
        log.info("测试结果:{}", a);
    }

}
